package com.github.andy0106.kersstjtl.api;

import com.github.andy0106.kersstjtl.files.Dir;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class TargetDir {
    private String name;
    private String target;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getTarget() {
        return target;
    }

    public void setTarget(String target) {
        this.target = target;
    }

    public boolean create(String pack_path) {
        try {
            Files.createDirectories(Paths.get(target.replace("${pack}", pack_path)+name));
        } catch (IOException e) {
            e.printStackTrace();
            return false;
        }
        return true;
    }

    public boolean create(Path pack_path) {
        return create(pack_path.toString());
    }

    public boolean create(Dir pack_path) {
        return create(pack_path.getPaths().toString());
    }
}
